<?php 
echo '<form action="index.php?page=login" method="post">'.$lang['login_username'].'&nbsp;:&nbsp;<input type="text" name="username"/><br/>
'.$lang['login_password'].'&nbsp;:&nbsp;<input type="password" name="password"/><br/>
<input type="submit" name="sent" value="'.$lang['login_submit'].'"/><br/></form>';

if(IsSet($_POST['sent'])) {
  $login = $_POST['username'];
  $password = $_POST['password'];
  
  if($login != "" && $password !="") {

    $password = hash('sha256',$password);

    $result = dibi::fetch("SELECT * FROM `users` WHERE (`name` LIKE %s",$login,") AND (`pass` LIKE %s",$password,")");
    

    if($result) {
      $_SESSION['auth'] = Array(
      'id' => $result['id'],
      'group' => $result['group'],
      'name' => $result['name'],
      'mail' => $result['mail'],
      'time' => Time()+1800
      );
      
      

      Header('Location:index.php?'.(SID?SID:""));
    } else {

      echo $lang['login_bad_name_or_pass'];
      
    };
  } else {

    echo $lang['login_empty_input'];
  };
};
?>